Skip to content

Replace Names with Strings in Macro API #4425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 30, 2018

Semantic names are not used enough to be really useful for the macro API. And
they are an additional concept to learn. So it's probably better to just use strings.
We had to duplicate one enum case for Types, to distinguish between TermNameRefs and
TypeNameRefs.

Semantic names are not used enough to be really useful for the macro API level. And
they are an additionl concept to learn. So it's probablu better to just use strings.
We had to duplicate one enum case for Types, to distinguish between TermNameRefs and
TypeNameRefs.
@smarter
Copy link
Member

smarter commented Apr 30, 2018

Does that mean users need to use "Foo$" to refer to the object Foo ?

@Blaisorblade
Copy link
Contributor

But TermName was meant to hide the mangling of identifiers. Would users see mangled strings now instead?

@odersky
Copy link
Contributor Author

odersky commented Apr 30, 2018

To the object's class, yes. Or we expose a constructor for the name.

@odersky
Copy link
Contributor Author

odersky commented Apr 30, 2018

@Blaisorblade

But TermName was meant to hide the mangling of identifiers. Would users see mangled strings now instead?

Yes, but we expose very few mangled names anyway. Basically: module class name <name>$ and super accessor name super$<name>. The other two were protected accessor and setter, but these will be generated after Tasty in the future. It does not seem worth to create a new abstraction for just these two.

@smarter
Copy link
Member

smarter commented Apr 30, 2018

What about name encoding? If I want Int#+ do I need to select "+" or "$plus" ?

@odersky
Copy link
Contributor Author

odersky commented Apr 30, 2018

Operators are unencoded. It's Int_+.

Maybe we should hide module class names as well or use a different encoding. E.g. object Foo instead of Foo$. Not sure about this one. Superaccessors look less problematic, they can just be treated as some compiler-generated definitions.

@Blaisorblade
Copy link
Contributor

It does not seem worth to create a new abstraction for just these two.

We either create and explain such a datatype, or we make mangling details part of the public API. So I don't think this patch actually reduces the cognitive overhead of the API — names seem the simplest part of this API.

@odersky odersky merged commit 5ecdd8a into scala:master Apr 30, 2018
@Blaisorblade Blaisorblade deleted the change-tasty-definitions branch May 1, 2018 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants